import 'dart:convert';

import 'package:get/get.dart';

import '../generated/json/base/json_field.dart';
import '../generated/json/setting_entity.g.dart';


@JsonSerializable()
class SettingEntity {

  @JSONField(name: "api_addr")
  String? apiAddr;
  // String? sip2ApiAddr;
  // String? picApiAddr;
  // String? faceApiAddr;
  // String? appKey;
  String? psw;
  String? auth = '1';
  @JSONField(name: "device_no")
  String? deviceNo;
  // String? softNo;
  String? deviceName;
  String? readerType;
  // String? websocketUrl;
  String? roomName;
  String? roomNo;
  String? columnNo;
  String? ledSerial;
  String? idSerial;
  String? analysisBook;
  String? analysisReader;
  String? ledRule;
  String? norms;
  int? rotate;
  int? sleepTime;
  int? actionTime;
  int? inventoryTime;
  bool? twoSided;
  // bool? main;
  bool? exchange;
  bool? action;
  bool? log;
  String? hfSerial;
  String? hfBaudRate;
  bool? isDev;

  List<SettingEntityPlace>? place;
  List<SettingEntityReader>? reader;


  SettingEntity();

  factory SettingEntity.fromJson(Map<String, dynamic> json) => $SettingEntityFromJson(json);

  Map<String, dynamic> toJson() => $SettingEntityToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class SettingEntityReader {

  String? readerAddr;
  String? readerPort;
  int? knot;
  //0启用 1禁用
  int? state = 0;

  RxBool visible = false.obs;

  SettingEntityReader();

  factory SettingEntityReader.fromJson(Map<String, dynamic> json) => $SettingEntityReaderFromJson(json);

  Map<String, dynamic> toJson() => $SettingEntityReaderToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}


@JsonSerializable()
class SettingEntityPlace {

  int? knot;
  String? place;
  String? placeName;
  String? readerAddr;
  String? readerPort;
  String? ant;
  String? led;
  String? broad;
  String? readerId;
  //0启用 1禁用
  int? state = 0;

  SettingEntityPlace();

  factory SettingEntityPlace.fromJson(Map<String, dynamic> json) => $SettingEntityPlaceFromJson(json);

  Map<String, dynamic> toJson() => $SettingEntityPlaceToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}


